#!/bin/bash

DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/conf

PIDS=`ps -ef | grep java | grep -v grep | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
    echo "ERROR: The script already started!"
    echo "PID: $PIDS"
    exit 1
fi

LIB_DIR=$DEPLOY_DIR/libs
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`

echo "classpath:$CONF_DIR:$LIB_JARS"
java -classpath $CONF_DIR:$LIB_JARS com.zyk.script.manager.main.ScriptBootstrap >> ./script.out 2>&1 &
echo "script runing"
